const City = require("../models/City");

// 获取所有热门城市
exports.getHotCities = async (req, res) => {
  try {
    const cities = await City.findAll({
      where: {
        hot: true,
      },
    });
    res.json(cities);
  } catch (error) {
    console.log(error);
    res.status(500).send("Server Error");
  }
};

// 添加热门城市
exports.addHotCity = async (req, res) => {
  console.log(123);
  try {
    const { name, country, image } = req.body;
    const city = await City.create({
      name,
      country,
      image,
      hot: true,
    });
    res.json({ success: true, ...city });
  } catch (error) {
    console.log(error);
    res.status(500).send("Server Error");
  }
};
